-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't open the wallet window after closing deposit flow #877
Conversation
The transaction sign window appears despite the rejection of the deposit. Let's make sure that the user does not close the window when the wallet opening action has already been triggered.
✅ Deploy Preview for acre-dapp ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for acre-dapp-testnet ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
To be able to cancel the deposit/withdrawal flow when a user closes the modal.
Cancel the withdrawal/deposit transaction when the user closes the flow modal.
Previously, `shouldOpenErrorModal` returned a wrong value. Let's check the shouldOpenErrorModal value using the current sessionId to make sure the data is up to date.
const sessionId = useRef(Math.random()) | ||
const { cancel, resolve, sessionIdToPromise } = useCancelPromise( | ||
sessionId.current, | ||
"Deposit cancelled", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can generate sessionId inside useCancelPromise
hook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously I used this solution but had the problem that shouldOpenErrorModal
was not returning the correct value for the right session.
Steps to reproduce:
- Reject the withdrawal request.
- Try again to do the withdrawal.
The problem was that the wallet window appeared and the dApp displayed a modal error. This happened because shouldOpenErrorModal
was true. Hook didn't return the right value for the session.
I decided to pass sessionId
to the hook to make sure we get the right value for shouldOpenErrorModal
. This solution solved the problem.
dapp/src/hooks/useCancelPromise.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we can hide the sessionIdToPromise
in useCancelPromise
hook and generate the session id here. For example:
useCancelPromise.ts
const sessionId = ... //generate session here
... // Implementation here
return {
cancel,
resolve,
options: { shouldOpenErrorModal: false }
}
b8e57d9
to
d196200
Compare
Closes #863
The transaction sign window appears despite the rejection of the deposit. Let's already use the solution for the withdrawal flow. The cancel logic was moved to
useCancelPromise
.Screen.Recording.2024-11-19.at.15.58.30.mov